﻿<script type="text/javascript">
    $(document).ready(function () {
        var p = new singlepage();
        p.c = "Way.Bus.WMS.SF.Controllers.SFSellOrderController";
        p.applyTo = "t1";
        p.onCommandClick = function (command, form, item) {
            if (command == "add") {
                form.setform("创建人", webjs.username);
                var myDate = new Date();
                var d = myDate.getFullYear() + "-" + myDate.getMonth() + "-" + myDate.getDate();
                form.setform("创建日期", d);
            }
        }

        p.onForeigned = function (sender, fdata, rows) {
            if (fdata.tablename.toString() == "Acc_Bus_BusinessCommodity" && sender.field.toString() == "MATERIALCODE") {
                var tt = p.datasource.post("GetKCNum", "materialId=" + rows.ID + "");
                if (tt.toString() != "") {
                    var row = sender.parent.selectrow();
                    var eb = sender.parent.geteditor("STAY1");
                    eb.actions.setValue(eb.target, tt, row);
                }
                //grid.load({ total: tt.length, rows: tt });
            }
        }
        p.onGridAddOrEdit = function (grid, cmd, item, ischild) {
            return false;
        }

        p.init();
    });


    function openWin(data) {
        window.hostWMS = data.item.ID;
        $("#t2").dialog({
            title: "" + data.item.ID + "",
            width: 1200,
            height: 620,
            maximizable: false,
            cache: false,
            href: "Views/PRO/Acctrue/SellStockOutOrderTest.htm"
        });
    }

    function openAutoNext(data) {
        var data1 = new datasource();
        data1.c = "Way.Bus.WMS.SF.Controllers.SFSellOrderController";
        var ck = data1.post("printvali", "sellorderid=" + data.item.ID);
        debugger;
        if (ck.errormsg != "Y") {
            console.info(ck.errormsg);
            alert(ck.errormsg);
            return;
        }
        //            window.parID = data.item.ID;
        //            window.whtype = data.item.WHTYPE;
        //            $("#t3").dialog({
        //                title: "销售退货单",
        //                width: 1200,
        //                height: 620,
        //                maximizable: false,
        //                cache: false,
        //                href: "SaleList.aspx?id=" + data.item.ID
        //            });
        window.open("/Views/Report_SF_aspx/SaleList.aspx?id=" + data.item.ID + "&p=c");
    }

    function openAutoTwo(data) {
        var data1 = new datasource();
        data1.c = "Way.Bus.WMS.SF.Controllers.SFSellOrderController";
        var ck = data1.post("printvali", "sellorderid=" + data.item.ID);
        if (ck.errormsg != "Y") {
            alert(ck.errormsg);
            return;
        }

        //            window.parID = data.item.ID;
        //            window.whtype = data.item.WHTYPE;
        //            $("#t3").dialog({
        //                title: "销售退货单",
        //                width: 1200,
        //                height: 620,
        //                maximizable: false,
        //                cache: false,
        //                href: "SaleList.aspx?id=" + data.item.ID
        //            });
        window.open("/Views/Report_SF_aspx/SaleList.aspx?id=" + data.item.ID + "&p=p");
    }

</script>
<div id="t1">
</div>
<div id="t2">
</div>
<div id="t3">
</div>
